<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateCruiseCheckErrorsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('cruise_check_errors', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('shopId')->default(0);
            $table->unsignedInteger('cruiseCheckDetailId')->default(0)->comment('巡检报告id');
            $table->tinyInteger('invalidType')->default(0)->comment('作废原因 1门店已暂停营业 2门店拒绝稽核 3任务生成错误');
            $table->string('conditionExplain', 255)->comment('情况说明');
            $table->tinyInteger('dealResult')->default(0)->comment('处理结果 0未处理 1暂不处理 2开具违约函');
            $table->tinyInteger('againstLevel')->default(0)->comment('违约级别 0默认 1警告 2触发');
            $table->tinyInteger('againstCategory')->default(0)->comment('违约分类 0默认 1私采');
            $table->tinyInteger('status')->default(0)->comment('0待提交 1以提交');
            $table->unsignedInteger('dealUid')->default(0)->comment('处理人id');
            $table->unsignedInteger('dealTime')->default(0)->comment('处理时间');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '稽核 - 异常报备单';


            $table->index('shopId', 'idx_shopId');
            $table->index('cruiseCheckDetailId', 'idx_cruiseCheckDetailId');
            $table->index('dealUid', 'idx_dealUid');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('cruise_check_errors');
    }
}
